{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 伯努利分布，即 随机二值 1， 0,,  1的概率为p, 0 的概率为 1-p\n",
    "# Numpy 中使用numpy.random.binomial(1,p)\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 交易者永远处于不利地位，因为有手续费\n",
    "# 实现casino() ： 假设有100个赌徒，每个赌徒都有1000000元，每个人都想在赌场玩1000次，\n",
    "# 在不同的胜率，赔率和手续费下casino函数返回总体统计结果\n",
    "gamblers = 10\n",
    "def casino(win_rate, win_once=1, loss_once=1, commission=0.01):\n",
    "    '''\n",
    "    简单设定 初始资金 10000 ，并且每个赌徒都想玩 10000次 quit输光了就停止\n",
    "    win_rate : 赢钱概率 \n",
    "    win_once: 每次赢钱输数量\n",
    "    loss_once:每次输钱数量 \n",
    "    commission:手续费 0.01 1% \n",
    "    '''\n",
    "    my_money = 10000 \n",
    "    play_cnt = 10000\n",
    "    '''这里有个问题，股市是根据你的交易量算手续费，这里简化，手续费每次都一样'''\n",
    "    for i in np.arange(0, play_cnt):\n",
    "        '''使用伯努利'''\n",
    "        w = np.random.binomial(1, win_rate)\n",
    "        if w: \n",
    "            '''赢了'''\n",
    "            my_money +=win_once\n",
    "        else:\n",
    "            my_money -=loss_once\n",
    "        my_money -=commission\n",
    "        if my_money < 0:\n",
    "            break\n",
    "    return my_money"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([1., 0., 0., 0., 1., 0., 1., 0., 0., 0., 0., 0., 0., 0., 2., 1., 0.,\n",
       "        1., 1., 2.]),\n",
       " array([ 7580.,  7773.,  7966.,  8159.,  8352.,  8545.,  8738.,  8931.,\n",
       "         9124.,  9317.,  9510.,  9703.,  9896., 10089., 10282., 10475.,\n",
       "        10668., 10861., 11054., 11247., 11440.]),\n",
       " <a list of 20 Patch objects>)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD4CAYAAAAEhuazAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAVf0lEQVR4nO3dfbBcd33f8fen8gMxEJCtC3FlyZJTl9ok+CG3wtQtmAKyTBoLGjqVmgRDYTRDcRuStlO7zNjUTGcgSUuH4GCUojrQYpMQSNRGxig8OS0R1bVjbMvG+Fom+EYqFpZjoGbsyHz7xx5ND9e79+69d++D57xfMzv3nN/vd3a/e87ez+6ePXs2VYUkqVv+2nIXIElaeoa/JHWQ4S9JHWT4S1IHGf6S1EEnLHcB/axZs6Y2bNiw3GVI0rPG7bff/p2qGht2/IoM/w0bNjAxMbHcZUjSs0aSP5/LeHf7SFIHGf6S1EGGvyR1kOEvSR1k+EtSBxn+ktRBs4Z/knVJvpjkviQHkvxynzFJ8sEkk0nuSnJhq++KJA80lytGfQckSXM3zHH+x4B/WVV3JHk+cHuSvVV1b2vMZcDZzeXlwIeBlyc5FbgWGAeqWXZ3VT020nshSZqTWV/5V9Xhqrqjmf4ecB+wdtqwrcDHqmcf8MIkpwOXAnur6mgT+HuBLSO9B5KkOZvTN3yTbAAuAL46rWst8HBrfqppG9Te77p3ADsA1q9fP5eyJC2iDVf90byX/eb7fnaElTw7PFvW19Af+CZ5HvD7wLuq6rvTu/ssUjO0P7OxamdVjVfV+NjY0KenkCTNw1Dhn+REesH/36rq032GTAHrWvNnAIdmaJckLaNhjvYJ8FHgvqr6jwOG7Qbe3Bz1cxHweFUdBm4FNidZnWQ1sLlpkyQto2H2+V8M/BJwd5I7m7Z/C6wHqKobgD3A64FJ4Angr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wV/Re6b1tlOsKGG8eEw8CH6L5lv8i1HYlcKBZr/vovRudcV0x4P9pgfW9sZl+Evg2vSfBeW3LhdQ3l9qAn2+tuzuAn5tt+w3aDjNdPL2DJHXQStztI0laZIa/JHWQ4S9JHWT4S1IHGf6S1EGGvyR1kOEvSR30/wBelukV9MXusgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 理想状态  胜率 10 赔率 10， 没有手续费\n",
    "heaven_moneys = [casino(win_rate=0.5, win_once=10, loss_once=10, commission=0)  for _ in np.arange(0, gamblers)]\n",
    "plt.hist(heaven_moneys, bins=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([5., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 2., 0., 0., 0.,\n",
       "        0., 0., 2.]),\n",
       " array([-8. , -7.7, -7.4, -7.1, -6.8, -6.5, -6.2, -5.9, -5.6, -5.3, -5. ,\n",
       "        -4.7, -4.4, -4.1, -3.8, -3.5, -3.2, -2.9, -2.6, -2.3, -2. ]),\n",
       " <a list of 20 Patch objects>)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAALRUlEQVR4nO3cfahkdR3H8c+nXXugMoMdy1qvt0ANKVK7boHYg4psbRhFiFIiWN2MLIXCh4SyJNh8yIIiWmwpqNTArFA0LdMQWuuurabtSiYrqdWuRGsiKdanP2auu27jztmZO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l6c5AsLNtxeavh7f4GkGUkfGPX3pOoe9Q5J+yVJb9tgR5J9Bz2vItvLJT2s7v7hQ5OeZ1i2b1R36+PW3v0/S3pbku0THWxEtqclXZfkjRMeZa/YfpOkX0p6ovdX81/tsCrJ3yY22BjYPkjS9YvtZ7Ir26dJOkPScUmeGHT8IFW3Ph6R9I7e7WMlLeYtg+MlbVnMke75ibo/C9k+RNILtUi/8cz2Abvcfb+keyY1y7CS/CHJ/kmmk0yr+508Ry7WSNs+eJe7J0raMqlZRmV7taRzJZ04jkhLzb49bxI+JunrvbPRf2vn16cuRidrcb+JOG+9pPW275H0lKTTqm57NHCx7cPV3frYKunjkx0HktbaPlTSfyU9qO7Z6GL1DUkvknRzd0NAG0a9gqXk1gcAYKeqWx8AgB5CDQDFEWoAKI5QA0BxhBoAiiPUAFAcoQaA4v4HV3KbqfI4eSQAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 存在老千 胜率 4 赔率 10， 没有手续费\n",
    "cheat_moneys = [casino(win_rate=0.5, win_once=4, loss_once=10, commission=0)  for _ in np.arange(0, gamblers)]\n",
    "plt.hist(cheat_moneys, bins=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0., 10.,  0.,  0.,\n",
       "         0.,  0.,  0.,  0.,  0.,  0.,  0.]),\n",
       " array([-20.5 , -20.45, -20.4 , -20.35, -20.3 , -20.25, -20.2 , -20.15,\n",
       "        -20.1 , -20.05, -20.  , -19.95, -19.9 , -19.85, -19.8 , -19.75,\n",
       "        -19.7 , -19.65, -19.6 , -19.55, -19.5 ]),\n",
       " <a list of 20 Patch objects>)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
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95o2sOZfZPkZ5dPAt4FPD9t3DGvdw/IrLl624pjrGV69AfwMy6/WuB+4B3jldq9pC9Z8LPAR4AHgXuC87V7Tob58K70kNeUpFElqyoBLUlMGXJKaMuCS1JQBl6SmDLgkNWXAJamp/wMzXxM8aJNtVAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 不存在老千 胜率 10 赔率 10， 手续费 10\n",
    "pay_moneys = [casino(win_rate=0.5, win_once=10, loss_once=10, commission=10)  for _ in np.arange(0, gamblers)]\n",
    "plt.hist(pay_moneys, bins=20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
